package com.Day10;

/**
 * @author: 若若叶
 * @date: 2021/7/18 14:14
 * FileName: MyLink
 * Description: 模拟链表
 */
public class MyLink implements Base{
    private MyNode header;


    @Override
    public void addNode(Object obj) {
        if (null==header){
            header = new MyNode(obj,null);
        }else {
            MyNode lastNode = findLastNode(header);
            lastNode.setNext(new MyNode(obj,null));
        }
    }

    private MyNode findLastNode(MyNode myNode) {
        while (myNode.getNext()!=null){
            myNode = myNode.getNext();
        }
        return myNode;
    }

    @Override
    public void deleteNode(Object obj) {
        //怎么获取上一个节点？
        //这里把下一个节点的地址直接给上一个节点的地址，就删除此节点。
        //添加一个的节点，用于存储上一个节点？那怎么传给上一个节点...
        //整不会了
        //MyNode index;
        while (header.getNext()!=null){
            if (header.getDate().equals(obj)){

            }
            //index = header;
        }

    }

    @Override
    public void modifyNode(Object obj) {

    }

    @Override
    public void selectNode(Object obj) {

    }
}
